From ce3e86b66960e355481b9f551f828d66702471f4 Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 13 Sep 2002 23:17:11 +0000 Subject: [PATCH] abort->fatal in more places. --- gpsbabel/geo.c | 11 +++++---- gpsbabel/gpx.c | 5 +++- gpsbabel/mapsource.c | 5 ++-- gpsbabel/mingw/testo | 56 ++++++++++++++++++++++++++++++++++++++++++++ gpsbabel/mkshort.c | 12 ++++++---- 5 files changed, 75 insertions(+), 14 deletions(-) create mode 100755 gpsbabel/mingw/testo diff --git a/gpsbabel/geo.c b/gpsbabel/geo.c index d7196b3d5..09a0c8d7e 100644 --- a/gpsbabel/geo.c +++ b/gpsbabel/geo.c @@ -29,6 +29,8 @@ static waypoint *wpt_tmp; FILE *fd; FILE *ofd; +#define MYNAME "geo" + static void tag_coord(const char **attrv) { @@ -134,12 +136,12 @@ geo_rd_init(const char *fname) { fd = fopen(fname, "r"); if (fd == NULL) { - abort(); + fatal(MYNAME ":Can not open %s for reading\n"); } psr = XML_ParserCreate(NULL); if (!psr) { - abort(); + fatal(MYNAME ":Can not create XML parser\n"); } XML_SetElementHandler(psr, geo_start, geo_end); @@ -157,7 +159,7 @@ geo_wr_init(const char *fname) { ofd = fopen(fname, "w"); if (ofd == NULL) { - abort(); + fatal(MYNAME ":Can not open %s for writing\n"); } } @@ -175,10 +177,9 @@ geo_read(void) while ((len = fread(buf, 1, sizeof(buf), fd))) { if (!XML_Parse(psr, buf, len, feof(fd))) { - fprintf(stderr, "Parse error at %d: %s\n", + fatal(MYNAME ":Parse error at %d: %s\n", XML_GetCurrentLineNumber(psr), XML_ErrorString(XML_GetErrorCode(psr))); - exit(1); } } diff --git a/gpsbabel/gpx.c b/gpsbabel/gpx.c index ff31881ff..58b84fefe 100644 --- a/gpsbabel/gpx.c +++ b/gpsbabel/gpx.c @@ -212,7 +212,9 @@ gpx_waypt_pr(waypoint *waypointp) fprintf(ofd, "\n", waypointp->position.latitude.degrees, waypointp->position.longitude.degrees); - fprintf(ofd, "%s\n", waypointp->shortname); + fprintf(ofd, "%s\n", global_opts.synthesize_shortnames ? + mkshort(waypointp->description) : + waypointp->shortname); fprintf(ofd, ""); fprintf(ofd, "", waypointp->description); fprintf(ofd, "\n"); @@ -235,6 +237,7 @@ gpx_write(void) { fprintf(ofd, "\n"); fprintf(ofd, "\n"); + setshort_length(32); waypt_disp_all(gpx_waypt_pr); fprintf(ofd, "\n"); } diff --git a/gpsbabel/mapsource.c b/gpsbabel/mapsource.c index 446da1426..a1e7e7621 100644 --- a/gpsbabel/mapsource.c +++ b/gpsbabel/mapsource.c @@ -32,8 +32,7 @@ mapsource_rd_init(const char *fname) { mapsource_file_in = fopen(fname, "r"); if (mapsource_file_in == NULL) { - fprintf(stderr, "Cannot open '%s' for reading\n", fname); - exit(1); + fatal("Cannot open '%s' for reading\n", fname); } } @@ -48,7 +47,7 @@ mapsource_wr_init(const char *fname) { mapsource_file_out = fopen(fname, "w"); if (mapsource_file_out == NULL) { - fprintf(stderr, "Cannot open '%s' for writing\n", fname); + fatal("Cannot open '%s' for writing\n", fname); exit(1); } } diff --git a/gpsbabel/mingw/testo b/gpsbabel/mingw/testo new file mode 100755 index 000000000..e494f3279 --- /dev/null +++ b/gpsbabel/mingw/testo @@ -0,0 +1,56 @@ +PNAME="wine -- ./gpsbabel" + +# Geocaching .loc +rm -f /tmp/gl.loc +${PNAME} -i geo -f geocaching.loc -o geo -F /tmp/gl.loc +diff /tmp/gl.loc ../reference + +# GPSUtil +rm -f /tmp/gu.wpt +${PNAME} -i geo -f geocaching.loc -o gpsutil -F /tmp/gu.wpt +diff /tmp/gu.wpt ../reference + +# GPSman +rm -f /tmp/gm.gm /tmp/gm.gm+ +${PNAME} -i geo -f geocaching.loc -o gpsman -F /tmp/gm.gm +${PNAME} -i gpsman -f /tmp/gm.gm -o gpsutil -F /tmp/gm.gm+ +diff /tmp/gm.gm+ /tmp/gu.wpt + +# GPX +rm -f /tmp/gl.gpx /tmp/gpx.gpx +${PNAME} -i geo -f geocaching.loc -o gpx -F /tmp/gl.gpx +${PNAME} -i gpx -f /tmp/gl.gpx -o gpsutil -F /tmp/gpx.gpx +diff /tmp/gpx.gpx /tmp/gu.wpt + +# Magellan Mapsend +rm -f /tmp/mm.mapsend /tmp/mm.gps +${PNAME} -i geo -f geocaching.loc -o mapsend -F /tmp/mm.mapsend +${PNAME} -i mapsend -f /tmp/mm.mapsend -o gpsutil -F /tmp/mm.gps +diff /tmp/mm.gps /tmp/gu.wpt + +# Garmin Mapsource +rm -f /tmp/mm.mapsource /tmp/ms.gps +#${PNAME} -i geo -f geocaching.loc -o mapsource -F /tmp/mm.mapsource +#${PNAME} -i mapsource -f /tmp/mm.mapsource -o gpsutil -F /tmp/ms.gps +# diff /tmp/ms.gps /tmp/gu.wpt + +# Magellan serial +# TODO + + +# CSV (Comma separated value) data. + +#${PNAME} -i geo -f geocaching.loc -o csv -F /tmp/csv.csv +#${PNAME} -i csv -f /tmp/csv.csv -o gpsutil -F /tmp/csv2.csv +#diff /tmp/csv2.csv /tmp/gu.wpt + +# PCX (Garmin mapsource import) file format +rm -f /tmp/mm.pcx /tmp/pcx.gps +${PNAME} -i geo -f geocaching.loc -o pcx -F /tmp/mm.pcx +${PNAME} -i pcx -f /tmp/mm.pcx -o gpsutil -F /tmp/pcx.gps +diff /tmp/mm.gps /tmp/gu.wpt + +# Magellan file format +${PNAME} -i magellan -f ../reference/magfile -o magellan -F /tmp/magfile +diff /tmp/magfile ../reference/magfile + diff --git a/gpsbabel/mkshort.c b/gpsbabel/mkshort.c index c943a0322..ffe954a45 100644 --- a/gpsbabel/mkshort.c +++ b/gpsbabel/mkshort.c @@ -11,6 +11,8 @@ static int target_len = DEFAULT_TARGET_LEN; static const char *badchars = DEFAULT_BADCHARS; static int mustupper = 0; +static const char needmem[] = + "mkshort: could not reallocate memory for string\n"; /* * This is the stuff that makes me ashamed to be a C programmer... @@ -87,7 +89,7 @@ mkshort(char *istring) if (!ostring) { - abort(); + fatal("mkshort: could not reallocate memory for string\n"); } /* @@ -97,7 +99,7 @@ mkshort(char *istring) strncmp(ostring, "the ", 4) == 0) { nstring = strdup(ostring + 4); if (!nstring) { - abort(); + fatal(needmem); } free(ostring); ostring = nstring; @@ -124,7 +126,7 @@ mkshort(char *istring) */ tstring = strdup(ostring); if (!tstring) { - abort(); + fatal(needmem); } l = strlen (tstring); cp = ostring; @@ -144,7 +146,7 @@ mkshort(char *istring) */ tstring = strdup(ostring); if (!tstring) { - abort(); + fatal(needmem); } l = strlen (tstring); cp = ostring; @@ -169,7 +171,7 @@ mkshort(char *istring) tstring = strdup(ostring); if (!tstring) { - abort(); + fatal(needmem); } /* -- 2.30.2